const https = require("https");
const http = require("http");

http
  .createServer((request, response) => {
    https.get(
      "https://www.jd.com/?cu=true&utm_source=baidu-pinzhuan&utm_medium=cpc&utm_campaign=t_288551095_baidupinzhuan&utm_term=0f3d30c8dba7459bb52f2eb5eba8ac7d_0_177095f8e6dc4c8c913e1a394929728e",
      (res) => {
        let count = 0;
        let result = "";
        // 监听接收到信息
        // 一次只能监听一小段内容
        res.on("data", (chunk) => {
          // console.log(data + "");
          result += chunk;
          count++;
        });
        // 监听结束
        res.on("end", () => {
          console.log(result);
          console.log(count);
          response.write(result);
          response.end();
        });
      }
    );
  })
  .listen(8000);
